package com.spboot.exts.entity.util;

import java.io.Serializable;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;

/**
 * 扩展mybatis plus 分页bean
 * 
 * @author acer
 *
 */
public class PageInfo<T> extends Page<T>  implements Serializable{

	private long pageCounts;// 总页数

	public PageInfo() {
		super();
	}

	public PageInfo(long current, long size) {
		super(current, size);
	}

	public long getPageCounts() {
		if (getSize() == 0L) {
			return 0L;
		}
		pageCounts = getTotal() / getSize();
		if (getTotal() % getSize() != 0L) {
			pageCounts += 1L;
		}
		return pageCounts;
	}
	
	public Long getStart(){
		return (getCurrent() - 1) * getSize();
	}

	@Override
	public String toString() {
		return "PageInfo [pageCounts=" + getPageCounts() + ", getStart()=" + getStart() + ", hasPrevious()=" + hasPrevious()
				+ ", hasNext()=" + hasNext() + ", getTotal()=" + getTotal() + ", getSize()=" + getSize()
				+ ", getCurrent()=" + getCurrent() + "]";
	}
	
	

}
